var app = getApp();
Page({
    data:{
        isIPX : app.globalData.isIPX,
        agtlevel : {},
		siteroot : app.siteInfo.siteroot.replace('app/index.php', ''),uniacid: app.siteInfo.uniacid,
    },
    onShow(){
        if( this.data.needback ){
            wx.navigateBack();
        }
    },
    onLoad:function(options){
        var self = this;
        
        self.setData({
            options : options,
        });
        app.com.auth(function(user){
            app.com.http('agent','POST',{op:'index'},0,false,'','',function(res){
                if (!res.data.errno) {
                    self.setData({
                        Pagetheme : res.data.data.params.style,
                        userinfo : res.data.data.userinfo,
                        params : res.data.data.params,
                        feedata : res.data.data.feedata,
                        agtlevel : res.data.data.agtlevel,
                        inited : true,
                    });

                    wx.setNavigationBarTitle({
                        title:  res.data.data.params.agentname+'中心',
                    });

                }else if( res.data.errno == 3 ){
                    self.setData({
                        needback : true,
                    }) 
                    wx.navigateTo({
                        url : '/zofui_sales/agent/join'
                    });
                }else{
                    app.com.alert(res.data.message);
                }
                
            });
        });
       
    },
    onPullDownRefresh: function () {
        if( this.data.isdown ) return false;
        this.setData({
            isdown : true,
        });
        this.onLoad( this.data.options );
        this.setData({
            isdown : false,
        });
        wx.stopPullDownRefresh();
    },
    onShareAppMessage : function(){
        var self = this;
        return {
            title: self.data.article.title,
            path: '',
            imageUrl : self.data.article.img,
        }
    },
    location : function( e ){
        app.com.location( e );
    },
    otherapp : function( e ){
        app.com.otherapp( e );
    },
    navigateto : function( e ){
        app.com.navigateto( e );
    },
    redirectto : function( e ){
        app.com.redirectto( e );
    },    
    callphone : function(e){
        app.com.callphone( e );
    },
    toweburl : function(e){
        app.com.toweburl( e );
    },
    copy(e){
        app.com.copy( e );
    },
    showimages : function( e ){
        app.com.showimages( e );
    },
    footNavigate(e){
        var url = e.currentTarget.dataset.url;
        wx.switchTab({
          url: url
        })
    },

})